<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function fn(ds) {
            if (ds instanceof Array) {
                ret = [...ds]
            } else {
                ret = { ...ds }
            }
            return ret
        }
        let arr = [1, 2, 3, 4, 5, [1, 2]];
        let ds = fn(arr);
        console.log(ds)



        let obj = {
            name: "清许",
            age: 24,
            sex: "女",
            hobbies: ["羽毛球", "购物",]
        }
        let ret1 = fn(obj);
        console.log(ret1);
        obj.name = "初见"
        console.log(obj)
        console.log(ret1)
    </script>
</body>

</html>